﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HRM.Entity;
using HRM.DAL;
using System.Data;

namespace HRM.BIZ
{
    public class EmployeeBiz: BaseBiz
    {
        public Employee Add(Employee emp)
        {
            return new EmployeeDAL().Add(emp);
        }

        public List<Employee> GetAll()
        {
            return new EmployeeDAL().GetAll();
        }

        public Employee GetByID(int ID)
        {
            return new EmployeeDAL().GetByID(ID);
        }

        public Employee GetByEmpID(string empID)
        {
            return new EmployeeDAL().GetByEmpID(empID);
        }

        public List<Employee> GetAll(bool isActive)
        {
            var query = from emps in GetAll()
                        where emps.Status == isActive
                        select emps;
            return query.ToList();
        }

        public List<Employee> GetAll(string status)
        {
            switch (status)
            {
                case "-1": //all
                    {
                        return GetAll();
                    }
                case "1": //active
                    {
                        return GetAll(true);
                    }
                case "0": //close
                    {
                        return GetAll(false);
                    }
                default:
                    {
                        return null;
                    }
            }
        }

        public Employee Update(Employee emp)
        {
            return new EmployeeDAL().Update(emp);
        }

        public DataSet GetEmployees()
        {
            return new EmployeeDAL().GetEmployees();
        }

        public DataSet GetByID(string empID)
        {
            return new EmployeeDAL().GetByID(empID);
        }
    }
}
